﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title></title>
    <script type="text/javascript" src="../scripts/jquery-1.8.0.js"></script>
    <script type="text/javascript" src="../scripts/jquery.validate.js"></script>
    <script type="text/javascript" src="../scripts/mKook.js"></script>
    <script type='text/javascript' src='../scripts/knockout-2.1.0.js'></script>
    <script type='text/javascript' src='../scripts/jquery.mobile-1.2.0-pre.js'></script>
    <link href="../Content/jquery.mobile-1.2.0-pre.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div data-role="page">
        <div data-role="header">
            <table class="headerTable">
                <tr>
                    <td width="30%">
                    </td>
                    <td>
                        <h1 data-bind="text: model.passportID"></h1>
                    </td>
                    <td width="30%">
                    </td>
                </tr>
            </table>
        </div>
        <div data-role="content">
            <button data-bind="click: capturePhoto">Capture Photo</button><br />
            <button data-bind="click: getPhotoFromLibrary">From Photo Library</button><br />
            <img id="largeImage" data-bind="attr: { src: model.imageURI }, style: { display: model.imageURI && model.imageURI().length > 0 ? 'block' : 'none' }" />
            <button data-bind="visible: model.imageURI && model.imageURI().length > 0, click: uploadPhoto">Upload photo</button>
        </div>
        <div data-role="footer">
            <p style="font-size: 10px; margin: 10px">© 2012 Danfoss and other contributors</p>
        </div>
    </div>
    <script>
        // Картинка
        function vmGetPicture(data) {
            var $this = this;

            $this.tmpl = 'GetPicture';
            $this.key = ['passportID'];
            $this.data = { passportID: '1', imageURI: '', imageData: '' };
            $this.model = {
                passportID: ko.observable($this.data.passportID),
                imageURI: ko.observable($this.data.imageURI),
            };
            // Called when a photo is successfully retrieved
            //
            function onPhotoURISuccess(uri) {
                // Uncomment to view the image file URI 
                // console.log(uri);

                $this.model.imageURI(uri);
            };
            $this.capturePhoto = function () {
                if (!cameraManager) {
                    return;
                }

                cameraManager.capturePhoto(onPhotoURISuccess);
            };
            $this.getPhotoFromLibrary = function () {
                if (!cameraManager) {
                    return;
                }

                cameraManager.getPhoto(cameraManager.pictureSource.PHOTOLIBRARY, onPhotoURISuccess);
            };
            $this.getPhotoFromAlbum = function () {
                if (!cameraManager) {
                    return;
                }

                cameraManager.getPhoto(cameraManager.pictureSource.SAVEDPHOTOALBUM, onPhotoURISuccess);
            };
        }

        ko.applyBindings(new vmGetPicture());
    </script>
</body>
</html>
